package com.tanhua.manager.controller;

import com.tanhua.manager.service.AnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuyp
 * @date 2021/02/21
 */
@RestController
@RequestMapping("/dashboard")
public class AnalysisController {

    @Autowired
    private AnalysisService analysisService;

    /**
     * 首页-概要信息统计
     * GET /dashboard/summary
     */
    @GetMapping("/summary")
    public ResponseEntity summary(){
        return analysisService.summary();
    }

    /**
     * 首页-折线图数据（新增、活跃用户、次日留存率）
     * GET /dashboard/users
     * @param sd 开始时间，毫秒值
     * @param ed 结束时间，毫秒值
     * @param type 操作类型。101新增，102活跃用户，103次日留存率
     */
    @GetMapping("/users")
    public ResponseEntity usersChartData(Long sd, Long ed, Integer type){
        return analysisService.usersChartData(sd, ed, type);
    }
}
